<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class WSUser{
    var $id = null;
    var $socket = null;
    var $server = null;
    var $handshake = false;
    var $_group = -1;
    var $_name = 0;
    var $_isHost = 0;
    var $_ready = 0;

    public function __construct($server, $socket)
    {
        $this->id = uniqid();
        $this->socket = $socket;
        $this->server = $server;
        $this->_isHost = false;
        //$this->_name = elgg_get_logged_in_user_entity()->guid;
    }

    public function setGroup($key)
    {
        $count = $this->server->countGroup($key);
        if( $count < 4){
            $this->_group = $key;
            $this->server->addToGroup($key, $this);
            return true;
        }
        else{
                return false;
        }
    }

    public function outGroup(){
        $this->_group = -1;
    }

    public function setHost($flag){
        if( $flag == 1)
            $this->_isHost = 1;
        else
            $this->_isHost = 0;
    }

    public function  setReady($flag){
        if( $flag == 1)
            $this->_ready = 1;
        else
            $this->_ready = 0;
    }

    public function getReady(){
        return $this->_ready;
    }

    public function getName(){
        return $this->_name;
    }

     public function setName($guid){
        $this->_name = $guid;
    }

    public function getHost(){
        return $this->_isHost;
    }
}
?>
